﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;

namespace WebsiteDownloader
{
    class HttpDownload
    {
        private string url;

        public HttpDownload(string weblink)
        {
            // TODO: Complete member initialization
            this.url = weblink;
        }

        public string getHttp()
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader httpReader = new StreamReader(response.GetResponseStream());
            try
            {
                return httpReader.ReadToEnd();
                httpReader.Close();
                httpReader.Dispose();
            }
            catch (Exception ex)
            {
                String error = "Not available for getting HTML codes: " + ex;
                return error;
                throw;
            }
        }

    }
}
